package day3.HomeWork;

/**
 * ClassName：Cust
 *
 * @Author：小鱼
 * @Create：2025-08-21 11:02
 */
public class Cust extends Thread{
    private Bum bum;

    public Cust(String name,Bum bum) {
        super(name);
        this.bum = bum;
    }

    @Override
    public void run(){
        while (true){
            synchronized (bum){
                while (bum.count<=0){
                    try {
                        bum.wait();
                    } catch (InterruptedException e) {
                        System.out.println(bum.type+"卖完了，等一等");
                    }
                }
                System.out.println(this.getName()+"吃"+bum.type+bum.count);
                bum.count--;
            }
        }
    }
}
